<extend name="Index/index" />
<block name="mycss"></block>

<block name="main">
    <div class="container">
        <div class="row">
            <!-- 主体左侧 -->
            <div class="col-md-7 col-md-offset-1">
                <div class="col-md-12">
                    <a href="<{:U('Topics/detail','tid='.$qinfo[0]['topic_id'])}>" class="radius_label" bh="<{$qinfo[0]['topic_id']}>"><{$qinfo[0]['topic_name']}></a>

                </div>
                <div class="col-md-12">
                    <p class="h4"><b><a href="<{:U('Question/detail','qid='.$qinfo[0]['id'])}>"  style="color:#000;"><{$qinfo[0]['name']}></a></b></p>
                    <p class="h6" style="color:#333;"><{$qinfo.0.content}></p>
                    <div class="divline"></div>
                    <p class="h5" style="color:#000;"><b><{$qinfo.0.answer_num}> 个回答</b></p>
                    <div class="divline"></div>
                </div>

                <!-- 回答正文, 有则遍历 -->
                <empty name="data">
                    <div class="col-md-12 mt20 text-center">
                        <p>该问题暂无更多答案,<a href="<{:U('Answer/index','qid='.$qinfo[0]['id'])}>">去回答</a></p>
                    </div>

                <else/>
                    <!-- 遍历问题答案 -->
                    <volist name="data" id="vo">
                        <div class="col-md-12 mt10">
                            <p>
                                <div class="w90 pull-left "><a href="<{:U('People/index', 'uid='.$vo['auid'])}>" auid="<{$vo['auid']}>"><{$vo.uname}></a></div>
                                <div class="w10 pull-right">
                                    <a href="<{:U('People/index', 'uid='.$vo['auid'])}>" auid="<{$vo['auid']}>">
                                        <img src="__PUBLIC__/imgs/<{$vo.uimg}>" width="25px" height="25px">
                                    </a>
                                </div>
                                <div class="clearfix"></div>
                            </p>
                            <p class="h6 text-muted">
                                <a href="" class="zan" zan="0" zannum="<{$vo.azan}>" question_id="<{$qinfo.0.id}>" answer_id="<{$vo.aid}>" style="color:#666">
                                    <empty name="vo">
                                        0  人赞同
                                    <else/>
                                        <{$vo.azan}>  人赞同
                                    </empty>
                                </a>
                            </p>

                            <div class="aid" aid="<{$vo.aid}>">
                                <{$vo.acontent}>
                            </div>
                            <div class="h6 text-muted">
                                <span>编辑于 <{$vo.atime}></span>
                                <span>
                                    <!-- <a href="" class="discuss" question_id="<{$qinfo.0.id}>" answer_id="<{$vo.aid}>"></a> -->
                                    <a href="" class="discuss" discuss="0" answer_id="<{$vo.aid}>" page="1" style="color:#666" onclick="return showDiscuss(this)">
                                        <empty name="vo.adnum">
                                            &ensp;0  人评论
                                        <else/>
                                            &ensp;<{$vo.adnum}>  人评论
                                        </empty>
                                    </a>
                                </span>
                                <span answer_id="<{$vo.aid}>">
                                    <a href="" class="thank" thank='0' question_id="<{$qinfo.0.id}>" answer_id="<{$vo.aid}>"><span class="glyphicon glyphicon-heart-empty"></span>感谢</a>&ensp;
                                    <!-- <a href="" class="share"  question_id="<{//$qinfo.0.id}>" answer_id="<{//$vo.aid}>"><span class="glyphicon glyphicon-share"></span>分享</a>&ensp; -->
                                    <a href=""  class="collect"  question_id="<{$qinfo.0.id}>" answer_id="<{$vo.aid}>" data-toggle="modal" data-target="#myModal<{$vo.aid}>"><span class="glyphicon glyphicon-paperclip"></span>收藏</a> · 
                                    <a href=""  class="helpless"  question_id="<{$qinfo.0.id}>" answer_id="<{$vo.aid}>">没有帮助</a> · 
                                    <a href=""  class="report" question_id="<{$qinfo.0.id}>" answer_id="<{$vo.aid}>">举报</a> · 
                                    <!-- <a href=""> -->
                                        <span class="">作者保留权利</span>
                                    <!-- </a> -->

                                    <php>if ($vo['auid'] == $_SESSION['home']['id']):</php>
                                        <span><a href="<{:U('Answer/edit', 'aid='.$vo['aid'])}>">修改答案</a></span>
                                    <php>endif;</php>
                                        
                                </span>

                                <!-- 模态框（Modal） -->
                                <div class="modal fade" id="myModal<{$vo.aid}>" tabindex="-1" role="dialog"  answer_id="<{$vo.aid}>"
                                   aria-labelledby="myModalLabel" aria-hidden="true">

                                    <div class="modal-dialog ">
                                        <div class="modal-content">
                                            <div class="modal-header bgq">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                                  &times;
                                                </button>
                                                <h4 class="modal-title" id="myModalLabel">
                                                 添加到收藏夹
                                                </h4>
                                            </div>
                                            <div class="modal-body">
                                                <table class="table table-hover ">
                                                    <for start="0" end="count($abc)">
                                                        <tr class="jiashou" sid="<{$abc[$i]['id']}>">
                                                            <td><{$abc[$i]['sname']}></td>
                                                        </tr>
                                                    </for>
                                                </table>
                                            </div>
                                            <div class="modal-footer biaog" bhh="<{$sto[$i]['id']}>">
                                                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                                                </button>
                                            </div>
                                        </div><!-- /.modal-content -->
                                    </div><!-- /.modal -->
                                </div><!-- end.modal -->
                            </div>

                            <!-- 答案评论显示 -->
                            <div id="dis<{$vo.aid}>" class="col-md-12" style="display:none; border:1px solid #ccc">
                            </div>

                            <div class="divline"></div>
                        </div>
                    </volist>
                <div class="col-md-12">
                    <p class="mt20"><a href="<{:U('Question/detail',array('qid'=>$qinfo[0]['id'],'p'=>$p))}>" class="btn btn-sm btn-default col-md-12">查看更多</a></p>
                </div>

                </empty>


                <!-- 分页模块 -->
                <!-- 更多 -->

                <!-- 回答模块 -->
                <div class="col-md-12 mt30">
                    <p class="h5" style="color:#000">回答问题: </p>
                    <p>
                        <div class="w90 pull-left"><a href="<{:U('People/index', 'uid='.$_SESSION['home']['id'])}>"><{$Think.session.home.name}></a></div>
                        <div class="w10 pull-right">
                            <a href="<{:U('People/index', 'uid='.$_SESSION['home']['id'])}>">
                                <img src="__PUBLIC__/imgs/<{$Think.session.home.image}>" width="25px" height="25px">
                            </a>
                        </div>
                        <div class="clearfix"></div>
                    </p>
                    <form action="<{:U('Answer/add')}>" method="post">
                        <input type="hidden" name="qid" value="<{$qinfo[0]['id']}>">
                        <p class="h6">添加评论内容: </p>
                        <textarea name="content" class="form-control"></textarea>
                        <p class="text-right mt10">
                        <button type="reset" class="btn btn-sm btn-warning">重置</button>
                        <button type="submit" class="btn btn-sm btn-primary">提交</button>
                        </p>
                    </form>
                    <p><a href="<{:U('Answer/index','qid='.$qinfo[0]['id'])}>" class="btn btn-sm btn-default col-md-12" target="_blank">您可以切换到写作模式, 编辑样式更丰富的回答</a></p>
                    <div class="divline"></div>
                </div>

                <div class="clearfix"></div>
                <div style="margin-bottom:50px;"></div>
            </div><!-- 左侧结束 -->
            <!-- 主体右侧 -->
            <div class="col-md-3">
            <div>
            <a href="" class="attend btn btn-success " question_id="<{$qinfo[0]['id']}>"><span class="glyphicon glyphicon-plus"></span>关注问题</a>&ensp;

            <button class="btn btn-default"><span class="glyphicon glyphicon-cog"></span>&nbsp;<span class="glyphicon glyphicon-triangle-bottom"></span></button>
            </div>
            <!-- <div class='mt20'>(48)人关注该问题</div>
            <div class="mt10" style="height:60px;background:#abcdef;">关注的人的头像</div> -->
            <hr>
            <!-- <div style="height:200px;background:#abcdef;border-radius:10px;">占位</div>
            <div class="mt10"><b>相关问题</b></div> -->
            <for start="0" end="count($die)">
            <div><a href="<{:U('Question/detail','qid='.$die[$i]['id'])}>"><{$die[$i]['name']}></a>&nbsp; <{$die[$i]['answer_num']}>个回答</div>
            <hr>
            </for>
            <!-- <div><b>问题状态</b></div>
            <div class="mt20">最近活动于几几年·<a href="">查看问题日志</a></div>
            <div class="mt10">别浏览(几)次,相关话题关注者(几)人</div> -->

            </div><!-- 右侧结束 -->
        </div>
    </div>

</block>
<block name="myjs">
    <script>
    $('.bianse').click(function(){
        if ($(this).text() == '关注问题') {
            $(this).text('取消关注').attr('class','btn btn-default');
        }else{
            $(this).text('关注问题').attr('class','btn btn-success');
        }
       
    })

    for (var i = 0; i < $('.jiashou').length; i++) {
        $($('.jiashou')[i]).click(function(){
            // var aid = $('.aid').attr('aid');
            var aid = $(this).parent().parent().parent().parent().parent().parent().attr('answer_id');
            var sid = $(this).attr('sid');

            // console.log(sid);
            // console.log(aid);

                $.ajax({
                    type:'get',
                    url:"<{:U('Question/jiashou')}>",
                    data:{'aid':aid,'sid':sid},
                    success:function(){
                        alert('已收藏');
                        window.location.reload();
                    }
                })
        });
    };

    </script>
</block>